<?php

declare(strict_types=1);

namespace App\Controller\Topic;


use App\Controller\BaseController;
use App\Request\Topic\TopicReplyRequest;
use App\Services\Topic\TopicReplyService;
use Hyperf\Context\Context;
use Hyperf\Di\Annotation\Inject;
use Psr\Http\Message\ResponseInterface;

class TopicReplyController extends BaseController
{
    #[Inject]
    public TopicReplyService $topicReplyService;

    /**
     * Note - 回贴
     * DateTime 2024/7/22 18:19
     * User Admin
     * @return ResponseInterface
     */
    public function reply(TopicReplyRequest $request)
    {
        // $request = $this->container->get(TopicReplyRequest::class);
        // $request->scene('reply')->validateResolved();
        $params = $this->request->post();
        $request->execute($params, 'reply');
        $user = Context::get('user');
        return $this->return($this->topicReplyService->reply($user, $params));

    }


    /**
     * Note - 回帖删除
     * DateTime 2024/7/22 19:02
     * User Admin
     * @return ResponseInterface
     */
    public function delete(TopicReplyRequest $request)
    {
        // $request = $this->container->get(TopicReplyRequest::class);
        // $request->scene('delete')->validateResolved();
        $params = $this->request->post();
        $request->execute($params, 'delete');
        return $this->return($this->topicReplyService->delete($params['ids']));

    }

    /**
     * Note - 点赞
     * DateTime 2024/7/22 18:26
     * User Admin
     * @return ResponseInterface
     */
    public function zan(TopicReplyRequest $request)
    {
        // $request = $this->container->get(TopicReplyRequest::class);
        // $request->scene('zan')->validateResolved();
        $params = $this->request->post();
        $request->execute($params, 'zan');
        $user = Context::get('user');
        return $this->return($this->topicReplyService->zan($user, $params));

    }


}
